// https://leetcode-cn.com/problems/container-with-most-water/
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <unordered_set>
#include <map>
#include <deque>

using namespace std;

class Solution {
public:
    int maxArea(vector<int>& height) {
		int left = 0;
		int right = height.size() - 1;
		int max = 0;
		while(right > left){
			int flag = 0;
			int tmp;
			if(height[left] < height[right]){
				flag = 1;
				tmp = (right-left)*height[left];
			}else{
				tmp = (right-left)*height[right];
			}
			if(tmp > max){
				max = tmp;
			}
			if(flag == 1){
				left++;
			}else{
				right--;
			}
		}
		return max;
    }
};

int main(){
	Solution so;
	vector<int> input = {1,8,6,2,5,4,8,3,7};
	int a = so.maxArea(input);
	
	cout << "max area:" << a << endl;
	return 0;
}